package com.qs.sckill.dao;

import com.qs.sckill.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserDao {

    @Select("select * from t_user where id=#{id}")
    User getUserById(@Param("id") long id);

    @Select("select * from t_user where phone=#{phone}")
    User getUserByPhone(@Param("phone") String phone);

    @Insert("insert into t_user(id, nick_name, password, salt, head, register_date, last_login_date, login_count,phone) " +
            "values(#{user.id},#{user.nickName},#{user.password},#{user.salt},#{user.head},#{user.registerDate},#{user.lastLoginDate},#{user.loginCount},#{user.phone})")
    void saveUser(@Param("user") User user);
}
